package com.thoughtworks.videorental.action;

import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.Collection;

import org.junit.Before;
import org.junit.Test;

import com.opensymphony.xwork2.Action;
import com.thoughtworks.videorental.domain.Customer;
import com.thoughtworks.videorental.domain.Transaction;
import com.thoughtworks.videorental.domain.repository.TransactionRepository;

public class ViewHistoryActionTest {
	
	private TransactionRepository transactionRepository;
	private ViewHistoryAction viewHistoryAction;
	
	@Before
	public void setUp() {
		transactionRepository = mock(TransactionRepository.class);
		viewHistoryAction = new ViewHistoryAction(transactionRepository);
	}

	@Test
	public void shouldReturnSuccessWhenRetrieveTransactionsForCustomer() throws Exception {
		Customer customer = new Customer("Padma","Padma","Padma");
		Collection<Transaction> transactions = new ArrayList<Transaction>();
		when(transactionRepository.transactionsBy(customer)).thenReturn(transactions);
		assertEquals(Action.SUCCESS, viewHistoryAction.execute());
	}
}
